#include <bits/stdc++.h>
using namespace std;

int main() {
    int dir[4][2] = {{0,  1},
                     {1,  0},
                     {0,  -1},
                     {-1, 0}};
    int n;
    cin >> n;

    vector <vector<int>> arr(n + 5, vector<int>(n + 5,-1));
    int x = 1, y = 1, fx = 0, step = 0;
    while (++step <= n * n) {
        arr[x][y] = step;
        int dx = x + dir[fx][0];
        int dy = y + dir[fx][1];
        if (dx < 1 or dx > n or dy < 1 or dy > n or arr[dx][dy] != -1)
            (fx += 1) %= 4;
        x += dir[fx][0];
        y += dir[fx][1];
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j)
            cout << arr[i][j] << ' ';
        cout << endl;
    }
    return 0;
}